package com.niuquan.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.List;

public class SpinnerAdapter extends BaseAdapter {
	
	private Context context;
	private List<String> myList;
	
	public SpinnerAdapter(Context context, List<String> myList) {
		this.context = context; 
		this.myList = myList;
	}
	
	public int getCount() {
		return myList.size(); 
	} 
	public Object getItem(int position) {
		return myList.get(position);
	} 
	public long getItemId(int position) {
		return position;
	} 
	
	public View getView(int position, View convertView, ViewGroup parent)
	{
		String myListItem = myList.get(position);
		return new MyAdapterView(this.context, myListItem);
	}

	class MyAdapterView extends LinearLayout { 
		public static final String LOG_TAG = "MyAdapterView";
		
		public MyAdapterView(Context context, String myListItem ) {
		super(context);
		this.setOrientation(HORIZONTAL); 
		
		LayoutParams params = new LayoutParams(200, LayoutParams.WRAP_CONTENT);
		params.setMargins(1, 1, 1, 1); 
		
		TextView name = new TextView( context ); 
		name.setText(myListItem );
		addView( name, params);
		}		 

		}

}